﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace canyinguanlixitong
{
    public partial class frmsy2xiugaiqw1 : Form
    {
        public frmsy2xiugaiqw1()
        {
            InitializeComponent();
        }
        string str = "Data Source=.;Initial Catalog=Supermarket management system;Integrated Security=True";
       //窗体加载
        private void frmsy2xiugaiqw1_Load(object sender, EventArgs e)
        {


        }
        public void xiugai() {
            SqlConnection conn = new SqlConnection(str);
            conn.Open();
            try
            {
            
               int i = Convert.ToInt32(this.textBox1.Text);
                string xia = this.textBox2.Text;
                string sql = "update dbo.commodity set spName='" + xia+ "' where spID='" + i+ "'select @@Identity";
                SqlCommand comm = new SqlCommand(sql, conn);
                int zx = comm.ExecuteNonQuery();
                if (zx > 0)
                {
                    MessageBox.Show("修改菜单成功");
                }
                else
                {
                    MessageBox.Show("失败");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally {
                conn.Close();
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            xiugai();
        }

      
    }
}
